package com.wang.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.mapper.DevMControlMapper;
import com.wang.pojo.DevMControl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author wcy
 * @date 2023-03-02 17:54
 */
@Service
@Transactional
public class DevMControlServiceImpl extends ServiceImpl<DevMControlMapper,DevMControl> implements DevMControlService {



    @Autowired
    private DevMControlMapper devControlMapper;

    @Override
    public List<DevMControl> selectDevControlByDevId(Integer devId) {
        return devControlMapper.selectDevControlByDevId(devId);
    }

    @Override
    public DevMControl selectDevControlById(Integer controlId) {
        return devControlMapper.selectDevControlById(controlId);
    }

    @Override
    public DevMControl selectDevControlByCommand(String command) {
        return devControlMapper.selectDevControlByCommand(command);
    }

    @Override
    public List<DevMControl> selectDevControlByFunId(Integer funId) {
        return devControlMapper.selectList(new LambdaQueryWrapper<DevMControl>().eq(DevMControl::getFunId,funId));
    }

    @Override
    public DevMControl selectDevControlByVo(Integer funId, String makeProperty) {

        LambdaQueryWrapper<DevMControl> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DevMControl::getFunId,funId);
        queryWrapper.eq(DevMControl::getMakeProperty,makeProperty);


        return  devControlMapper.selectOne(queryWrapper);
    }

    @Override
    public DevMControl selectByControlNameAndDevId(String yushuiControlName, Integer devId) {
        return devControlMapper.selectOne(new LambdaQueryWrapper<DevMControl>()
                .eq(DevMControl::getControlName,yushuiControlName)
                .eq(DevMControl::getDevId,devId)
        );
    }
}
